# 测试 Swagger UI 中文注释显示
Write-Host "=== 智慧医疗 RAG 系统 - Swagger UI 中文注释测试 ===" -ForegroundColor Green

# 等待 API 启动
Write-Host "等待 API 启动..." -ForegroundColor Yellow
Start-Sleep -Seconds 5

# 测试 API 是否可访问
try {
    $swaggerJson = Invoke-RestMethod -Uri "https://localhost:56704/swagger/v1/swagger.json" -Method Get
    Write-Host "✓ API 可访问" -ForegroundColor Green
    
    # 检查 API 标题
    Write-Host "API 标题: $($swaggerJson.info.title)" -ForegroundColor Cyan
    Write-Host "API 描述: $($swaggerJson.info.description)" -ForegroundColor Cyan
    
    # 检查中文注释
    Write-Host "`n=== 检查中文注释 ===" -ForegroundColor Yellow
    
    # 检查端点注释
    $endpointsWithChinese = 0
    foreach ($path in $swaggerJson.paths.PSObject.Properties) {
        foreach ($method in $path.Value.PSObject.Properties) {
            if ($method.Value.summary -and $method.Value.summary -match "[\u4e00-\u9fff]") {
                $endpointsWithChinese++
                Write-Host "✓ $($path.Name) $($method.Name): 包含中文注释" -ForegroundColor Green
            }
        }
    }
    
    # 检查数据模型注释
    $schemasWithChinese = 0
    foreach ($schema in $swaggerJson.components.schemas.PSObject.Properties) {
        if ($schema.Value.description -and $schema.Value.description -match "[\u4e00-\u9fff]") {
            $schemasWithChinese++
            Write-Host "✓ $($schema.Name): 包含中文注释" -ForegroundColor Green
        }
    }
    
    Write-Host "`n=== 测试结果 ===" -ForegroundColor Yellow
    Write-Host "包含中文注释的端点: $endpointsWithChinese" -ForegroundColor Green
    Write-Host "包含中文注释的数据模型: $schemasWithChinese" -ForegroundColor Green
    
    if ($endpointsWithChinese -gt 0 -and $schemasWithChinese -gt 0) {
        Write-Host "`n🎉 测试通过！Swagger UI 中文注释配置成功！" -ForegroundColor Green
        Write-Host "请在浏览器中访问: https://localhost:56704/swagger" -ForegroundColor Cyan
        Write-Host "您将看到完整的中文 API 文档和示例数据！" -ForegroundColor Cyan
    } else {
        Write-Host "`n❌ 测试失败！未找到中文注释" -ForegroundColor Red
    }
    
} catch {
    Write-Host "❌ API 无法访问: $($_.Exception.Message)" -ForegroundColor Red
    Write-Host "请确保 API 正在运行" -ForegroundColor Yellow
}

Write-Host "`n=== 测试完成 ===" -ForegroundColor Green 